package com;



import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class MasterServlet
 */
@WebServlet("/MasterServlet")
public class MasterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public MasterServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	
		String v1=request.getParameter("mvat");
		String v2=request.getParameter("cst");
		String v3=request.getParameter("eligible");
		String v4=request.getParameter("location");
		String v5=request.getParameter("email");
		long v6=Long.parseLong(request.getParameter("phone"));
		int v7=Integer.parseInt(request.getParameter("block"));
		String v8=request.getParameter("building");
		String v9=request.getParameter("street");
		String v10=request.getParameter("area");
		String v11=request.getParameter("city");
		String v12=request.getParameter("dist");
		long v13=Long.parseLong(request.getParameter("pin"));
		
		
		System.out.println(v1);
		//int mobile=Integer.parseInt(request.getParameter("mobile"));
		        try{
		         Class.forName("com.mysql.jdbc.Driver");
		           Connection con = DriverManager.getConnection("jdbc:mysql://localhost/amit", "root", "root");
		           Statement st=con.createStatement();
		           int i=st.executeUpdate("insert into master_info(mvat,cstrc,eligible,location,email,phoneno,block,building,street,area,city,district,pin) values('"+v1+"','"+v2+"','"+v3+"','"+v4+"','"+v5+"','"+v6+"',"+v7+",'"+v8+"','"+v9+"','"+v10+"','"+v11+"','"+v12+"',"+v13+")");
		        //out.println("Data is successfully inserted!");
		        //alert("Data is inserted successfully");
		        con.close();
		        }
		        catch(Exception e){
		        System.out.print(e);
		        e.printStackTrace();
		        }
	}

}
